/**
 * 
 */
package com.changil.nowonchangilchurch.page.info;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.changil.nowonchangilchurch.R;
import com.changil.nowonchangilchurch.common.Constants;
import com.changil.nowonchangilchurch.page.BaseActivity;
import com.changil.nowonchangilchurch.page.LatestDetailFragment;

/**
 * @author zeropol2
 *
 */
public class InfoActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	protected void initLayout() {
		mHeader.setHeaderText(getString(R.string.church_info));
		mHeader.setHeaderColor(R.color.color_info_n);
		mTabs.setIndicatorColorResource(R.color.color_info_n);
	}

	protected void defineAdapter() {
		mAdapter = new InfoPagerAdapter(getSupportFragmentManager());
	}
	
	private class InfoPagerAdapter extends FragmentPagerAdapter {
		private final String[] TITLES = { getString(R.string.worship_info),
				getString(R.string.history_info),
				getString(R.string.map_info),
				getString(R.string.shuttle_info)};

		public InfoPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		@Override
		public CharSequence getPageTitle(int position) {
			return TITLES[position];
		}

		@Override
		public int getCount() {
			return TITLES.length;
		}

		@Override
		public Fragment getItem(int position) {
			Fragment nextFragment = null;
			if(0 == position) {
				nextFragment = WorshipInfoFragment.newInstance();
			} else if( 1 == position) {
				nextFragment = LatestDetailFragment.newInstance(Constants.BOARD_ID_HISTORY);
			} else if( 2 == position) {
				nextFragment = MapInfoFragment.newInstance();
			} else if( 3 == position) {
				nextFragment = LatestDetailFragment.newInstance(Constants.BOARD_ID_SHUTTLE);
			}
			return nextFragment;
		}

	}
}
